package com.lemon.day012;

import com.lemon.day012.JDBCUtil;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import static com.lemon.day012.JDBCUtil.getConnection;

public class JDBCDemo {
	public static void main(String[] args) throws IOException {
		// 查询手机号为123456用户的id，regname
		String sql = "select id,regname from member where mobilephone=?";
		String value="13517315120";
		/*
		 * String url=
		 * "jdbc:mysql://db.lemonban.com:3306/future?useUnicode=true&characterEncoding=utf-8";
		 * String user="test"; String password="test";
		 */
		// 1.创建一个连接
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		try {
			Map<String, Object> map = JDBCUtil.query(sql, value);
			Set<String> columnLabels = map.keySet();
			for (String columnLabel : columnLabels) {
				System.out.println(columnLabel+map.get(columnLabel));
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		// 关闭资源
		finally {
			try {
				if (connection != null) {
					connection.close();
				}
				if (preparedStatement != null) {
					preparedStatement.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}

		}
	}


}
